package com.example.demo.controller;

import com.example.demo.common.LogAnnotation;
import com.example.demo.service.WalletLogService;
import com.example.demo.service.WalletService;
import com.example.demo.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wallet")
public class WalletController {

    @Autowired
    private WalletService walletService;
    @Autowired
    private WalletLogService walletLogService;

    /*
     * 查询用户钱包余额。
     * 更具用户id查找。该业务默认用户id为 1
     * */
    @GetMapping()
    @LogAnnotation(operation = "查询账户")
    public Result get() {
        return walletService.get();
    }

    /*
     * 用户消费100元接口
     * */
    @PostMapping("/payHundred")
    @LogAnnotation(operation = "支付100元")
    public Result payHundred() {
        return walletService.payHundred();
    }

    /*
     * 退款20
     * */
    @PostMapping("/getTwenty")
    @LogAnnotation(operation = "退款20元")
    public Result getTwenty() {
        return walletService.getTwenty();
    }

    /*
     * 明细
     * */
    @PostMapping("/getDetailed")
    public Result getDetailed() {
        return walletLogService.getDetailed();
    }

}
